<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 
 * @param $html
 * @param $filename
 * @param $papel (array de tamanhos disponivel e utilizado do script 'dompdf/include/cpdf_adapter.cls.php')
 * @param $orientacao ('portrait' ou 'landscape')
 * @param $stream
 */
function pdf_create($html, $filename, $papel = "a4", $orientacao = "portrait", $stream=TRUE) 
{
    require_once("dompdf/dompdf_config.inc.php");
    spl_autoload_register('DOMPDF_autoload');
    
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper($papel, $orientacao);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename.".pdf");
    } else {
        $CI =& get_instance();
        $CI->load->helper('file');
        write_file("./invoices_temp/invoice_$filename.pdf", $dompdf->output());
    }
}
?>